home *** CD-ROM | disk | FTP | other *** search
/ Super PC 26 / Super PC 26 (Shareware).iso / spc / util / fractint / source / fractint.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-03-26  |  25.6 KB  |  897 lines

  1. /* FRACTINT.H - common structures and values for the FRACTINT routines */
  2.  
  3. #ifndef FRACTINT_H
  4. #define FRACTINT_H
  5.  
  6. #include <math.h>
  7. #ifndef PORT_H
  8. #include "port.h"
  9. #endif
  10. #ifndef BIGNUM_DEFINED
  11. #include "bignum.h"
  12. #include "bigflt.h"
  13. #endif
  14.  
  15. typedef BYTE BOOLEAN;
  16.  
  17. #ifndef C6
  18. #define _fastcall    /* _fastcall is a Microsoft C6.00 extension */
  19. #endif
  20.  
  21. #ifndef XFRACT
  22. typedef int SEGTYPE;
  23. typedef unsigned USEGTYPE;
  24. #ifdef __TURBOC__
  25. #   define _bios_printer(a,b,c)   biosprint((a),(c),(b))
  26. #   define _bios_serialcom(a,b,c) bioscom((a),(c),(b))
  27. #else
  28. #ifndef __WATCOMC__
  29. #ifndef MK_FP
  30. #   define MK_FP(seg,off) (VOIDFARPTR )( (((long)(seg))<<16) | \
  31.                                           ((unsigned)(off)) )
  32. #endif
  33. #endif
  34. #endif
  35. #else
  36. typedef char * SEGTYPE;
  37. typedef char * USEGTYPE;
  38. #   define MK_FP(seg,off) (VOIDFARPTR )(seg+off)
  39. #include <sys/types.h> /* need size_t */
  40. #endif
  41.  
  42.  
  43. #ifndef XFRACT
  44. #define clock_ticks() clock()
  45. #endif
  46.  
  47. #ifdef XFRACT
  48. #define _fstrcpy(to,from) strcpy(to,from)
  49. #define _fmemmove(a,b,c) (bn_t)memmove(a,b,c)
  50. #define _fmemset(a,b,c) (bn_t)memset(a,b,c)
  51. #define _fmemcpy(a,b,c) (bn_t)memcpy(a,b,c)
  52. #define difftime(now,then) ((now)-(then))
  53. #endif
  54.  
  55. /* for gotos in former FRACTINT.C pieces */
  56. #define RESTART           1
  57. #define IMAGESTART        2
  58. #define RESTORESTART      3
  59. #define CONTINUE          4
  60.  
  61. /* these are used to declare arrays for file names */
  62. #define FILE_MAX_PATH  80       /* max length of path+filename  */
  63. #define FILE_MAX_DIR   80       /* max length of directory name */
  64. #define FILE_MAX_DRIVE  3       /* max length of drive letter   */
  65. #define FILE_MAX_FNAME  9       /* max length of filename       */
  66. #define FILE_MAX_EXT    5       /* max length of extension      */
  67.  
  68. #define MAX_CODES   4095        /* for decoder arrays */
  69.  
  70. #define MAXPARAMS 10        /* maximum number of parameters */
  71. #define MAXPIXELS 2048        /* Maximum pixel count across/down the screen */
  72. #define DEFAULTASPECT ((float)0.75)/* Assumed overall screen dimensions, y/x  */
  73. #define DEFAULTASPECTDRIFT ((float)0.02) /* drift of < 2% is forced to 0% */
  74.  
  75. struct videoinfo {        /* All we need to know about a Video Adapter */
  76.     char    name[26];    /* Adapter name (IBM EGA, etc)        */
  77.     char    comment[26];    /* Comments (UNTESTED, etc)        */
  78.     int    keynum;     /* key number used to invoked this mode */
  79.                 /* 2-10 = F2-10, 11-40 = S,C,A{F1-F10}    */
  80.     int    videomodeax;    /* begin with INT 10H, AX=(this)    */
  81.     int    videomodebx;    /*        ...and BX=(this)    */
  82.     int    videomodecx;    /*        ...and CX=(this)    */
  83.     int    videomodedx;    /*        ...and DX=(this)    */
  84.                 /* NOTE:  IF AX==BX==CX==0, SEE BELOW    */
  85.     int    dotmode;    /* video access method used by asm code */
  86.                 /*    1 == BIOS 10H, AH=12,13 (SLOW)    */
  87.                 /*    2 == access like EGA/VGA    */
  88.                 /*    3 == access like MCGA        */
  89.                 /*    4 == Tseng-like  SuperVGA*256    */
  90.                 /*    5 == P'dise-like SuperVGA*256   */
  91.                 /*    6 == Vega-like     SuperVGA*256    */
  92.                 /*    7 == "Tweaked" IBM-VGA ...*256  */
  93.                 /*    8 == "Tweaked" SuperVGA ...*256 */
  94.                 /*    9 == Targa Format        */
  95.                 /*    10 = Hercules            */
  96.                 /*    11 = "disk video" (no screen)   */
  97.                 /*    12 = 8514/A            */
  98.                 /*    13 = CGA 320x200x4, 640x200x2    */
  99.                 /*    14 = Tandy 1000         */
  100.                 /*    15 = TRIDENT  SuperVGA*256    */
  101.                 /*    16 = Chips&Tech SuperVGA*256    */
  102.     int    xdots;        /* number of dots across the screen    */
  103.     int    ydots;        /* number of dots down the screen    */
  104.     int    colors;     /* number of colors available        */
  105.     };
  106.  
  107. typedef struct videoinfo far        VIDEOINFO;
  108. #define INFO_ID     "Fractal"
  109. typedef    struct fractal_info FRACTAL_INFO;
  110.  
  111. /*
  112.  * Note: because non-MSDOS machines store structures differently, we have
  113.  * to do special processing of the fractal_info structure in loadfile.c.
  114.  * Make sure changes to the structure here get reflected there.
  115.  */
  116. #ifndef XFRACT
  117. #define FRACTAL_INFO_SIZE sizeof(FRACTAL_INFO)
  118. #else
  119. /* This value should be the MSDOS size, not the Unix size. */
  120. #define FRACTAL_INFO_SIZE 502
  121. #endif
  122.  
  123. struct fractal_info        /*  for saving data in GIF file     */
  124. {
  125.     char  info_id[8];        /* Unique identifier for info block */
  126.     short iterationsold;    /* Pre version 18.24 */
  127.     short fractal_type;        /* 0=Mandelbrot 1=Julia 2= ... */
  128.     double xmin;
  129.     double xmax;
  130.     double ymin;
  131.     double ymax;
  132.     double creal;
  133.     double cimag;
  134.     short videomodeax;
  135.     short videomodebx;
  136.     short videomodecx;
  137.     short videomodedx;
  138.     short dotmode;
  139.     short xdots;
  140.     short ydots;
  141.     short colors;
  142.     short version;        /* used to be 'future[0]' */
  143.     float parm3;
  144.     float parm4;
  145.     float potential[3];
  146.     short rseed;
  147.     short rflag;
  148.     short biomorph;
  149.     short inside;
  150.     short logmap;
  151.     float invert[3];
  152.     short decomp[2];
  153.     short symmetry;
  154.             /* version 2 stuff */
  155.     short init3d[16];
  156.     short previewfactor;
  157.     short xtrans;
  158.     short ytrans;
  159.     short red_crop_left;
  160.     short red_crop_right;
  161.     short blue_crop_left;
  162.     short blue_crop_right;
  163.     short red_bright;
  164.     short blue_bright;
  165.     short xadjust;
  166.     short eyeseparation;
  167.     short glassestype;
  168.             /* version 3 stuff, release 13 */
  169.     short outside;
  170.             /* version 4 stuff, release 14 */
  171.     double x3rd;      /* 3rd corner */
  172.     double y3rd;
  173.     char stdcalcmode;      /* 1/2/g/b */
  174.     char useinitorbit;      /* init Mandelbrot orbit flag */
  175.     short calc_status;      /* resumable, finished, etc */
  176.     long tot_extend_len;  /* total length of extension blocks in .gif file */
  177.     short distest;
  178.     short floatflag;
  179.     short bailoutold;
  180.     long calctime;
  181.     BYTE trigndx[4];      /* which trig functions selected */
  182.     short finattract;
  183.     double initorbit[2];  /* init Mandelbrot orbit values */
  184.     short periodicity;      /* periodicity checking */
  185.             /* version 5 stuff, release 15 */
  186.     short pot16bit;      /* save 16 bit continuous potential info */
  187.     float faspectratio;   /* finalaspectratio, y/x */
  188.     short system;       /* 0 for dos, 1 for windows */
  189.     short release;      /* release number, with 2 decimals implied */
  190.     short flag3d;       /* stored only for now, for future use */
  191.     short transparent[2];
  192.     short ambient;
  193.     short haze;
  194.     short randomize;
  195.             /* version 6 stuff, release 15.x */
  196.     short rotate_lo;
  197.     short rotate_hi;
  198.     short distestwidth;
  199.             /* version 7 stuff, release 16 */
  200.     double dparm3;
  201.     double dparm4;
  202.             /* version 8 stuff, release 17 */
  203.     short fillcolor;
  204.             /* version 9 stuff, release 18 */
  205.     double mxmaxfp;
  206.     double mxminfp;
  207.     double mymaxfp;
  208.     double myminfp;
  209.     short zdots;
  210.     float originfp;
  211.     float depthfp;
  212.     float heightfp;
  213.     float widthfp;
  214.     float distfp;
  215.     float eyesfp;
  216.     short orbittype;
  217.     short juli3Dmode;
  218.     short maxfn;
  219.     short inversejulia;
  220.     double dparm5;
  221.     double dparm6;
  222.     double dparm7;
  223.     double dparm8;
  224.     double dparm9;
  225.     double dparm10;
  226.             /* version 10 stuff, release 19 */
  227.     long bailout;
  228.     short bailoutest;
  229.     long iterations;
  230.     short bf_math;
  231.     short bflength;
  232.     short yadjust;        /* yikes! we left this out ages ago! */
  233.     short old_demm_colors;
  234.     short future[42];      /* for stuff we haven't thought of yet */
  235. };
  236.  
  237. #define ITEMNAMELEN 18     /* max length of names in .frm/.l/.ifs/.fc */
  238. struct history_info    
  239. {
  240.     short fractal_type;
  241.     double xmin;
  242.     double xmax;
  243.     double ymin;
  244.     double ymax;
  245.     double creal;
  246.     double cimag;
  247.     double potential[3];
  248.     short rseed;
  249.     short rflag;
  250.     short biomorph;
  251.     short inside;
  252.     short logmap;
  253.     double invert[3];
  254.     short decomp;
  255.     short symmetry;
  256.     short init3d[16];
  257.     short previewfactor;
  258.     short xtrans;
  259.     short ytrans;
  260.     short red_crop_left;
  261.     short red_crop_right;
  262.     short blue_crop_left;
  263.     short blue_crop_right;
  264.     short red_bright;
  265.     short blue_bright;
  266.     short xadjust;
  267.     short eyeseparation;
  268.     short glassestype;
  269.     short outside;
  270.     double x3rd;      
  271.     double y3rd;
  272.     char stdcalcmode;
  273.     char three_pass;
  274.     char useinitorbit;      
  275.     short distest;
  276.     short bailoutold;
  277.     BYTE trigndx[4];      
  278.     short finattract;
  279.     double initorbit[2];  
  280.     short periodicity;      
  281.     short pot16bit;      
  282.     short release;
  283.     short save_release;
  284.     short flag3d; 
  285.     short transparent[2];
  286.     short ambient;
  287.     short haze;
  288.     short randomize;
  289.     short rotate_lo;
  290.     short rotate_hi;
  291.     short distestwidth;
  292.     double dparm3;
  293.     double dparm4;
  294.     short fillcolor;
  295.     double mxmaxfp;
  296.     double mxminfp;
  297.     double mymaxfp;
  298.     double myminfp;
  299.     short zdots;
  300.     float originfp;
  301.     float depthfp;
  302.     float heightfp;
  303.     float widthfp;
  304.     float distfp;
  305.     float eyesfp;
  306.     short orbittype;
  307.     short juli3Dmode;
  308.     char  maxfn;
  309.     short major_method;
  310.     short minor_method;
  311.     double dparm5;
  312.     double dparm6;
  313.     double dparm7;
  314.     double dparm8;
  315.     double dparm9;
  316.     double dparm10;
  317.     long bailout;
  318.     short bailoutest;
  319.     long iterations;
  320.     short bf_math;
  321.     short bflength;
  322.     short yadjust;
  323.     short old_demm_colors;
  324.     char filename[80];
  325.     char itemname[ITEMNAMELEN+1];
  326.     unsigned char dac[256][3];
  327. };
  328.  
  329. typedef struct history_info HISTORY;
  330.  
  331. #define MAXVIDEOMODES 300    /* maximum entries in fractint.cfg      */
  332. #ifndef XFRACT
  333. #define MAXVIDEOTABLE 40        /* size of the resident video modes table */
  334. #else
  335. #define MAXVIDEOTABLE 2         /* size of the resident video modes table */
  336. #endif
  337.  
  338. #define AUTOINVERT -123456.789
  339. #define ENDVID 22400   /* video table uses extra seg up to here */
  340.  
  341. #define N_ATTR 8            /* max number of attractors    */
  342.  
  343. extern    long     l_at_rad;    /* finite attractor radius  */
  344. extern    double     f_at_rad;    /* finite attractor radius  */
  345.  
  346. #define NUMIFS      64     /* number of ifs functions in ifs array */
  347. #define IFSPARM    7     /* number of ifs parameters */
  348. #define IFS3DPARM 13     /* number of ifs 3D parameters */
  349.  
  350. struct moreparams
  351. {
  352.    int      type;                        /* index in fractalname of the fractal */
  353.    char     *param[MAXPARAMS-4];    /* name of the parameters */
  354.    double   paramvalue[MAXPARAMS-4];     /* default parameter values */
  355. };
  356.  
  357. typedef struct moreparams far       MOREPARAMS;
  358.  
  359. struct fractalspecificstuff
  360. {
  361.    char  *name;             /* name of the fractal */
  362.                     /* (leading "*" supresses name display) */ 
  363.    char  *param[4];            /* name of the parameters */
  364.    double paramvalue[4];         /* default parameter values */
  365.    int     helptext;            /* helpdefs.h HT_xxxx, -1 for none */
  366.    int     helpformula;            /* helpdefs.h HF_xxxx, -1 for none */
  367.    unsigned flags;             /* constraints, bits defined below */
  368.    float xmin;                /* default XMIN corner */
  369.    float xmax;                /* default XMAX corner */
  370.    float ymin;                /* default YMIN corner */
  371.    float ymax;                /* default YMAX corner */
  372.    int     isinteger;            /* 1 if integerfractal, 0 otherwise */
  373.    int     tojulia;            /* mandel-to-julia switch */
  374.    int     tomandel;            /* julia-to-mandel switch */
  375.    int     tofloat;            /* integer-to-floating switch */
  376.    int     symmetry;            /* applicable symmetry logic
  377.                        0 = no symmetry
  378.                       -1 = y-axis symmetry (If No Params)
  379.                        1 = y-axis symmetry
  380.                       -2 = x-axis symmetry (No Parms)
  381.                        2 = x-axis symmetry
  382.                       -3 = y-axis AND x-axis (No Parms)
  383.                        3 = y-axis AND x-axis symmetry
  384.                       -4 = polar symmetry (No Parms)
  385.                        4 = polar symmetry
  386.                        5 = PI (sin/cos) symmetry
  387.                        6 = NEWTON (power) symmetry
  388.                                 */
  389. #ifdef XFRACT
  390.    int (*orbitcalc)();    /* function that calculates one orbit */
  391. #else
  392.    int (*orbitcalc)(void);    /* function that calculates one orbit */
  393. #endif
  394.    int (*per_pixel)(void);    /* once-per-pixel init */
  395.    int (*per_image)(void);    /* once-per-image setup */
  396.    int (*calctype)(void);    /* name of main fractal function */
  397.    int orbit_bailout;        /* usual bailout value for orbit calc */
  398. };
  399.  
  400. struct alternatemathstuff
  401. {
  402.    int type;            /* index in fractalname of the fractal */
  403.    int math;             /* kind of math used */
  404. #ifdef XFRACT
  405.    int (*orbitcalc)();    /* function that calculates one orbit */
  406. #else
  407.    int (*orbitcalc)(void);    /* function that calculates one orbit */
  408. #endif
  409.    int (*per_pixel)(void);    /* once-per-pixel init */
  410.    int (*per_image)(void);    /* once-per-image setup */
  411. };
  412.  
  413. typedef struct alternatemathstuff ALTERNATE;
  414.  
  415. /* defines for symmetry */
  416. #define  NOSYM        0
  417. #define  XAXIS_NOPARM  -1
  418. #define  XAXIS        1
  419. #define  YAXIS_NOPARM  -2
  420. #define  YAXIS        2
  421. #define  XYAXIS_NOPARM -3
  422. #define  XYAXIS     3
  423. #define  ORIGIN_NOPARM -4
  424. #define  ORIGIN     4
  425. #define  PI_SYM_NOPARM -5
  426. #define  PI_SYM     5
  427. #define  XAXIS_NOIMAG  -6
  428. #define  XAXIS_NOREAL    6
  429. #define  NOPLOT        99
  430. #define  SETUP_SYM    100
  431.  
  432. /* defines for inside/outside */
  433. #define ITER        -1
  434. #define REAL        -2
  435. #define IMAG        -3
  436. #define MULT        -4
  437. #define SUM         -5
  438. #define ATAN        -6
  439. #define ZMAG       -59
  440. #define BOF60      -60
  441. #define BOF61      -61
  442. #define EPSCROSS  -100
  443. #define STARTRAIL -101
  444. #define PERIOD    -102
  445.  
  446. /* defines for bailoutest */
  447. enum bailouts { Mod, Real, Imag, Or, And };
  448. enum Major  {breadth_first, depth_first, random_walk, random_run};
  449. enum Minor  {left_first, right_first};
  450.  
  451. /* bitmask defines for fractalspecific flags */
  452. #define  NOZOOM     1    /* zoombox not allowed at all          */
  453. #define  NOGUESS    2    /* solid guessing not allowed          */
  454. #define  NOTRACE    4    /* boundary tracing not allowed        */
  455. #define  NOROTATE    8    /* zoombox rotate/stretch not allowed  */
  456. #define  NORESUME      16    /* can't interrupt and resume          */
  457. #define  INFCALC       32    /* this type calculates forever        */
  458. #define  TRIG1           64    /* number of trig functions in formula */
  459. #define  TRIG2          128
  460. #define  TRIG3          192
  461. #define  TRIG4          256
  462. #define  WINFRAC      512    /* supported in WinFrac                */
  463. #define  PARMS3D     1024    /* uses 3d parameters                  */
  464. #define  OKJB        2048    /* works with Julibrot                 */
  465. #define  MORE        4096    /* more than 4 parms                   */
  466. #define  BAILTEST    8192    /* can use different bailout tests     */
  467. #define  BF_MATH    16384    /* supports arbitrary precision        */
  468. #define  LD_MATH    32768    /* supports long double                */
  469.  
  470. extern struct fractalspecificstuff far fractalspecific[];
  471. extern struct fractalspecificstuff far *curfractalspecific;
  472.  
  473. #define DEFAULTFRACTALTYPE    ".gif"
  474. #define ALTERNATEFRACTALTYPE    ".fra"
  475.  
  476. #ifndef _CMPLX_DEFINED
  477. #include "cmplx.h"
  478. #endif
  479.  
  480. #ifndef sqr
  481. #define sqr(x) ((x)*(x))
  482. #endif
  483.  
  484. #ifndef lsqr
  485. #define lsqr(x) (multiply((x),(x),bitshift))
  486. #endif
  487.  
  488. #define CMPLXmod(z)      (sqr((z).x)+sqr((z).y))
  489. #define CMPLXconj(z)    ((z).y =  -((z).y))
  490. #define LCMPLXmod(z)       (lsqr((z).x)+lsqr((z).y))
  491. #define LCMPLXconj(z)    ((z).y =  -((z).y))
  492.  
  493. typedef  _LCMPLX LCMPLX;
  494.  
  495. /* 3D stuff - formerly in 3d.h */
  496. #ifndef dot_product
  497. #define dot_product(v1,v2)  ((v1)[0]*(v2)[0]+(v1)[1]*(v2)[1]+(v1)[2]*(v2)[2])  /* TW 7-09-89 */
  498. #endif
  499.  
  500. #define    CMAX    4   /* maximum column (4 x 4 matrix) */
  501. #define    RMAX    4   /* maximum row     (4 x 4 matrix) */
  502. #define    DIM       3   /* number of dimensions */
  503.  
  504. typedef double MATRIX [RMAX] [CMAX];  /* matrix of doubles */
  505. typedef int   IMATRIX [RMAX] [CMAX];  /* matrix of ints    */
  506. typedef long  LMATRIX [RMAX] [CMAX];  /* matrix of longs   */
  507.  
  508. /* A MATRIX is used to describe a transformation from one coordinate
  509. system to another.  Multiple transformations may be concatenated by
  510. multiplying their transformation matrices. */
  511.  
  512. typedef double VECTOR [DIM];  /* vector of doubles */
  513. typedef int   IVECTOR [DIM];  /* vector of ints    */
  514. typedef long  LVECTOR [DIM];  /* vector of longs   */
  515.  
  516. /* A VECTOR is an array of three coordinates [x,y,z] representing magnitude
  517. and direction. A fourth dimension is assumed to always have the value 1, but
  518. is not in the data structure */
  519.  
  520.  
  521. #define PI 3.14159265358979323846
  522.  
  523. #define SPHERE      init3d[0]        /* sphere? 1 = yes, 0 = no  */
  524. #define ILLUMINE  (FILLTYPE>4)    /* illumination model        */
  525.  
  526. /* regular 3D */
  527. #define XROT      init3d[1]    /* rotate x-axis 60 degrees */
  528. #define YROT      init3d[2]    /* rotate y-axis 90 degrees */
  529. #define ZROT      init3d[3]    /* rotate x-axis  0 degrees */
  530. #define XSCALE      init3d[4]    /* scale x-axis, 90 percent */
  531. #define YSCALE      init3d[5]    /* scale y-axis, 90 percent */
  532.  
  533. /* sphere 3D */
  534. #define PHI1      init3d[1]    /* longitude start, 180     */
  535. #define PHI2      init3d[2]    /* longitude end ,   0        */
  536. #define THETA1      init3d[3]        /* latitude start,-90 degrees */
  537. #define THETA2      init3d[4]        /* latitude stop,  90 degrees */
  538. #define RADIUS      init3d[5]    /* should be user input */
  539.  
  540. /* common parameters */
  541. #define ROUGH      init3d[6]    /* scale z-axis, 30 percent */
  542. #define WATERLINE init3d[7]    /* water level            */
  543. #define FILLTYPE  init3d[8]    /* fill type            */
  544. #define ZVIEWER   init3d[9]    /* perspective view point   */
  545. #define XSHIFT      init3d[10]    /* x shift */
  546. #define YSHIFT      init3d[11]    /* y shift */
  547. #define XLIGHT      init3d[12]    /* x light vector coordinate */
  548. #define YLIGHT      init3d[13]    /* y light vector coordinate */
  549. #define ZLIGHT      init3d[14]    /* z light vector coordinate */
  550. #define LIGHTAVG  init3d[15]    /* number of points to average */
  551.  
  552. #ifndef TRUE
  553. #define TRUE 1
  554. #define FALSE 0
  555. #endif
  556.  
  557. /* Math definitions (normally in float.h) that are missing on some systems. */
  558. #ifndef FLT_MIN
  559. #define FLT_MIN 1.17549435e-38
  560. #endif
  561. #ifndef FLT_MAX
  562. #define FLT_MAX 3.40282347e+38
  563. #endif
  564. #ifndef DBL_EPSILON
  565. #define DBL_EPSILON 2.2204460492503131e-16
  566. #endif
  567.  
  568. /* gcc doesn't like the real DBL_MAX for some reason */
  569. #ifdef XFRACT
  570. #ifdef DBL_MAX
  571. #undef DBL_MAX
  572. #define DBL_MAX 1.79769313486231e+308
  573. #endif
  574. #endif
  575.  
  576. #ifndef XFRACT
  577. #define UPARR "\x18"
  578. #define DNARR "\x19"
  579. #define RTARR "\x1A"
  580. #define LTARR "\x1B"
  581. #else
  582. #define UPARR "K"
  583. #define DNARR "J"
  584. #define RTARR "L"
  585. #define LTARR "H"
  586. #endif
  587.  
  588. #define JIIM  0
  589. #define ORBIT 1
  590.  
  591. struct workliststuff    /* work list entry for std escape time engines */
  592. {
  593.     int xxstart;    /* screen window for this entry */
  594.     int xxstop;
  595.     int yystart;
  596.     int yystop;
  597.     int yybegin;    /* start row within window, for 2pass/ssg resume */
  598.     int sym;    /* if symmetry in window, prevents bad combines */
  599.     int pass;    /* for 2pass and solid guessing */
  600. };
  601.  
  602. typedef struct workliststuff        WORKLIST;
  603.  
  604.  
  605. #define MAXCALCWORK 12
  606.  
  607. struct coords {
  608.     int x,y;
  609.     };
  610.  
  611. struct dblcoords {
  612.     double x,y;
  613.     };
  614.  
  615. extern BYTE trigndx[];
  616. extern void (*ltrig0)(void), (*ltrig1)(void), (*ltrig2)(void), (*ltrig3)(void);
  617. extern void (*dtrig0)(void), (*dtrig1)(void), (*dtrig2)(void), (*dtrig3)(void);
  618.  
  619. struct trig_funct_lst
  620. {
  621.     char *name;
  622.     void (*lfunct)(void);
  623.     void (*dfunct)(void);
  624.     void (*mfunct)(void);
  625. } ;
  626. extern struct trig_funct_lst trigfn[];
  627.  
  628. /* function prototypes */
  629.  
  630. extern    void   (_fastcall *plot)(int, int, int);
  631.  
  632. /* for overlay return stack */
  633.  
  634. #define BIG 100000.0
  635.  
  636. #define CTL(x) ((x)&0x1f)
  637.  
  638. /* nonalpha tests if we have a control character */
  639. #define nonalpha(c) ((c)<32 || (c)>127)
  640.  
  641. /* keys */
  642. #define   INSERT     1082
  643. #define   DELETE     1083
  644. #define   PAGE_UP     1073
  645. #define   PAGE_DOWN     1081
  646. #define   CTL_HOME     1119
  647. #define   CTL_END     1117
  648. #define   LEFT_ARROW     1075
  649. #define   RIGHT_ARROW     1077
  650. #define   UP_ARROW     1072
  651. #define   DOWN_ARROW     1080
  652. #define   LEFT_ARROW_2     1115
  653. #define   RIGHT_ARROW_2  1116
  654. #define   UP_ARROW_2     1141
  655. #define   DOWN_ARROW_2     1145
  656. #define   HOME         1071
  657. #define   END         1079
  658. #define   ENTER      13
  659. #define   ENTER_2     1013
  660. #define   CTL_ENTER      10
  661. #define   CTL_ENTER_2    1010
  662. #define   CTL_PAGE_UP    1132
  663. #define   CTL_PAGE_DOWN  1118
  664. #define   CTL_MINUS      1142
  665. #define   CTL_PLUS       1144
  666. #define   CTL_INSERT     1146
  667. #define   CTL_DEL        1147
  668. #define   CTL_BACKSLASH  28
  669. #define   F1         1059
  670. #define   F2         1060
  671. #define   F3         1061
  672. #define   F4         1062
  673. #define   F5         1063
  674. #define   F6         1064
  675. #define   F7         1065
  676. #define   F8         1066
  677. #define   F9         1067
  678. #define   F10         1068
  679. #define   BACKSPACE     8
  680. #define   TAB            9
  681. #define   CTL_TAB        1148
  682. #define   ALT_TAB        1165
  683. #define   BACK_TAB     1015  /* shift tab */
  684. #define   ESC            27
  685. #define   SPACE          32
  686. #define   SF1            1084
  687. #define   SF2            1085
  688. #define   SF3            1086
  689. #define   SF4            1087
  690. #define   SF5            1088
  691. #define   SF6            1089
  692. #define   SF7            1090
  693. #define   SF8            1091
  694. #define   SF9            1092
  695. #define   SF10           1093
  696. /* text colors */
  697. #define BLACK       0
  698. #define BLUE       1
  699. #define GREEN       2
  700. #define CYAN       3
  701. #define RED       4
  702. #define MAGENTA    5
  703. #define BROWN       6 /* dirty yellow on cga */
  704. #define WHITE       7
  705. /* use values below this for foreground only, they don't work background */
  706. #define GRAY       8 /* don't use this much - is black on cga */
  707. #define L_BLUE       9
  708. #define L_GREEN   10
  709. #define L_CYAN      11
  710. #define L_RED      12
  711. #define L_MAGENTA 13
  712. #define YELLOW      14
  713. #define L_WHITE   15
  714. #define INVERSE 0x8000 /* when 640x200x2 text or mode 7, inverse */
  715. #define BRIGHT    0x4000 /* when mode 7, bright */
  716. /* and their use: */
  717. extern BYTE txtcolor[];
  718. #define C_TITLE       txtcolor[0]+BRIGHT
  719. #define C_TITLE_DEV      txtcolor[1]
  720. #define C_HELP_HDG      txtcolor[2]+BRIGHT
  721. #define C_HELP_BODY      txtcolor[3]
  722. #define C_HELP_INSTR      txtcolor[4]
  723. #define C_HELP_LINK      txtcolor[5]+BRIGHT
  724. #define C_HELP_CURLINK      txtcolor[6]+INVERSE
  725. #define C_PROMPT_BKGRD      txtcolor[7]
  726. #define C_PROMPT_TEXT      txtcolor[8]
  727. #define C_PROMPT_LO      txtcolor[9]
  728. #define C_PROMPT_MED      txtcolor[10]
  729. #ifndef XFRACT
  730. #define C_PROMPT_HI      txtcolor[11]+BRIGHT
  731. #else
  732. #define C_PROMPT_HI      txtcolor[11]
  733. #endif
  734. #define C_PROMPT_INPUT      txtcolor[12]+INVERSE
  735. #define C_PROMPT_CHOOSE   txtcolor[13]+INVERSE
  736. #define C_CHOICE_CURRENT  txtcolor[14]+INVERSE
  737. #define C_CHOICE_SP_INSTR txtcolor[15]
  738. #define C_CHOICE_SP_KEYIN txtcolor[16]+BRIGHT
  739. #define C_GENERAL_HI      txtcolor[17]+BRIGHT
  740. #define C_GENERAL_MED      txtcolor[18]
  741. #define C_GENERAL_LO      txtcolor[19]
  742. #define C_GENERAL_INPUT   txtcolor[20]+INVERSE
  743. #define C_DVID_BKGRD      txtcolor[21]
  744. #define C_DVID_HI      txtcolor[22]+BRIGHT
  745. #define C_DVID_LO      txtcolor[23]
  746. #define C_STOP_ERR      txtcolor[24]+BRIGHT
  747. #define C_STOP_INFO      txtcolor[25]+BRIGHT
  748. #define C_TITLE_LOW      txtcolor[26]
  749. #define C_AUTHDIV1      txtcolor[27]+INVERSE
  750. #define C_AUTHDIV2      txtcolor[28]+INVERSE
  751. #define C_PRIMARY      txtcolor[29]
  752. #define C_CONTRIB      txtcolor[30]
  753.  
  754. /* structure for xmmmoveextended parameter */
  755. struct XMM_Move
  756.   {
  757.     unsigned long   Length;
  758.     unsigned int    SourceHandle;
  759.     unsigned long   SourceOffset;
  760.     unsigned int    DestHandle;
  761.     unsigned long   DestOffset;
  762.   };
  763.  
  764. /* structure passed to fullscreen_prompts */
  765. struct fullscreenvalues
  766. {
  767.    int type;   /* 'd' for double, 'f' for float, 's' for string,   */
  768.            /* 'D' for integer in double, '*' for comment */
  769.            /* 'i' for integer, 'y' for yes=1 no=0              */
  770.            /* 0x100+n for string of length n           */
  771.            /* 'l' for one of a list of strings                 */
  772.            /* 'L' for long */
  773.    union
  774.    {
  775.       double dval;    /* when type 'd' or 'f'  */
  776.       int    ival;    /* when type is 'i'      */
  777.       long   Lval;    /* when type is 'L'      */
  778.       char   sval[16];    /* when type is 's'      */
  779.       char  far *sbuf;    /* when type is 0x100+n  */
  780.       struct {        /* when type is 'l'      */
  781.      int  val;    /*   selected choice     */
  782.      int  vlen;    /*   char len per choice */
  783.      char **list;    /*   list of values     */
  784.      int  llen;    /*   number of values     */
  785.       } ch;
  786.    } uval;
  787. };
  788.  
  789. #define   FILEATTR     0x37       /* File attributes; select all but volume labels */
  790. #define   HIDDEN     2
  791. #define   SYSTEM     4
  792. #define   SUBDIR     16
  793.  
  794. struct DIR_SEARCH        /* Allocate DTA and define structure */
  795. {
  796.      char path[21];        /* DOS path and filespec */
  797.      char attribute;        /* File attributes wanted */
  798.      int  ftime;        /* File creation time */
  799.      int  fdate;        /* File creation date */
  800.      long size;         /* File size in bytes */
  801.      char filename[13];     /* Filename and extension */
  802. };
  803.  
  804. extern struct DIR_SEARCH DTA;   /* Disk Transfer Area */
  805.  
  806. typedef struct palett
  807. {
  808.    BYTE red;
  809.    BYTE green;
  810.    BYTE blue;
  811. }
  812. Palettetype;
  813.  
  814. struct ext_blk_2 {
  815.    char got_data;
  816.    int length;
  817.    char far *resume_data;
  818.    };
  819.  
  820. struct ext_blk_3 {
  821.    char got_data;
  822.    char form_name[40];
  823.    };
  824.  
  825. struct ext_blk_4 {
  826.    char got_data;
  827.    int length;
  828.    int far *range_data;
  829.    };
  830.  
  831. struct ext_blk_5 {
  832.    char got_data;
  833.    int length;
  834.    char far *apm_data;
  835.    };
  836.  
  837. struct affine
  838. {
  839.    /* weird order so a,b,e and c,d,f are vectors */
  840.    double a;
  841.    double b;
  842.    double e;
  843.    double c;
  844.    double d;
  845.    double f;
  846. };
  847.  
  848. #define sign(x) (((x) < 0) ? -1 : ((x) != 0)  ? 1 : 0)
  849.  
  850. #if (_MSC_VER >= 700)
  851. typedef char __based(__segname("_CODE")) FCODE;
  852. #else
  853. typedef char far FCODE;
  854. #endif
  855.  
  856. #if (_MSC_VER >= 700)
  857. typedef BYTE __based(__segname("_CODE")) BFCODE;
  858. #else
  859. typedef BYTE far BFCODE;
  860. #endif
  861.  
  862. #if (_MSC_VER >= 700)
  863. typedef int __based(__segname("_CODE")) IFCODE;
  864. #else
  865. typedef int far IFCODE;
  866. #endif
  867.  
  868. #if (_MSC_VER >= 700)
  869. typedef unsigned int __based(__segname("_CODE")) UIFCODE;
  870. #else
  871. typedef unsigned int far UIFCODE;
  872. #endif
  873.  
  874. #if (_MSC_VER >= 700)
  875. typedef long __based(__segname("_CODE")) LFCODE;
  876. #else
  877. typedef long far LFCODE;
  878. #endif
  879.  
  880. #if (_MSC_VER >= 700)
  881. typedef double __based(__segname("_CODE")) DFCODE;
  882. #else
  883. typedef double far DFCODE;
  884. #endif
  885. #endif
  886.  
  887. #if _MSC_VER == 800 
  888. #ifndef FIXTAN_DEFINED
  889. /* !!!!! stupid MSVC tan(x) bug fix !!!!!!!!            */
  890. /* tan(x) can return -tan(x) if -pi/2 < x < pi/2       */
  891. /* if tan(x) has been called before outside this range. */
  892. double fixtan( double x );
  893. #define tan fixtan
  894. #define FIXTAN_DEFINED
  895. #endif
  896. #endif
  897.